package com.chuangxin.data.chazidian;

import com.chuangxin.data.core.IDBasedFetcher;
import com.chuangxin.data.core.io.DataOutput;
import com.chuangxin.data.core.io.FileWriter;
import org.jsoup.nodes.Document;

import java.io.File;

/**
 * Created by Dawnwords on 2015/2/1.
 */
public class XiaoHuaFetcher extends IDBasedFetcher {

    private static final int start = 30525;
    private static final int end = 81440;
    private static final String template = "http://www.chazidian.com/xiaohua${id}/";

    public XiaoHuaFetcher(DataOutput output) {
        super(output, start, end, template);
    }

    @Override
    protected TitleContent processDoc(Document doc, String url) {
        String title = doc.select("div.article_title > h1").eq(0).html();
        String content = doc.select("div.article_detail").eq(0).html();
        return new TitleContent(title, content);
    }

    public static void main(String[] args) {
        new XiaoHuaFetcher(new FileWriter("E:" + File.separator + "chazidian" + File.separator + "xiaohua")).execute();
    }
}
